<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
  <head>
    <title>A canvas path recycle example</title>
    <meta name="DC.creator" content="Kamiel Martinet, http://www.martinet.nl/">
    <meta name="DC.publisher" content="Mozilla Developer Center, http://developer.mozilla.org">

	<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]-->

    <script>
      function boot() {
        drawShape(document.getElementById('canvas'));
        drawShape(document.getElementById('vmlcanvas'));
      }
      function drawShape(canvas){
        var ctx = canvas.getContext('2d');

        ctx.fillStyle = "blue";
        ctx.beginPath();
        ctx.moveTo(50, 10);
        ctx.lineTo(90, 90);
        ctx.lineTo(10, 90);
        ctx.closePath();
        ctx.fill();

        ctx.translate(20, 20);
        ctx.scale(1.2, 1.2);
        ctx.fillStyle = "green";
        ctx.fill();

        ctx.translate(40, 40);
        ctx.scale(1.2, 1.2);
        ctx.fillStyle = "yellow";
        ctx.fill();
      }
    </script>
    <style type="text/css">
      body { margin: 20px; font-family: arial,verdana,helvetica; background: #fff;}
      h1 { font-size: 140%; font-weight:normal; color: #036; border-bottom: 1px solid #ccc; }
      canvas { border: 2px solid #000; float: left; margin-right: 20px; margin-bottom: 20px; }
      pre { float:left; display:block; background: rgb(238,238,238); border: 1px dashed #666; padding: 15px 20px; margin: 0 0 10px 0; }
    </style>
  </head>

  <body onload="boot();">
    <h1>A canvas <code>path recycle</code> example</h1>
    <div>
      <canvas id="canvas" width="150" height="150"></canvas>
      <canvas id="vmlcanvas" class="vml" width="150" height="150"></canvas>
      <pre>
      function boot() {
        drawShape(document.getElementById('canvas'));
        drawShape(document.getElementById('vmlcanvas'));
      }
      function drawShape(canvas){
        var ctx = canvas.getContext('2d');

        ctx.fillStyle = "blue";
        ctx.beginPath();
        ctx.moveTo(50, 10);
        ctx.lineTo(90, 90);
        ctx.lineTo(10, 90);
        ctx.closePath();
        ctx.fill();

        ctx.translate(20, 20);
        ctx.scale(1.2, 1.2);
        ctx.fillStyle = "green";
        ctx.fill();

        ctx.translate(40, 40);
        ctx.scale(1.2, 1.2);
        ctx.fillStyle = "yellow";
        ctx.fill();
      }
      </pre>
    </div>
  </body>

</html>
